package cn.bitkit.assist.code.creator;

import cn.bitkit.assist.code.BaseCreator;
import cn.bitkit.base.util.StringUtil;
import cn.bitkit.tools.file.TextHelper;

public class ServiceCreator extends BaseCreator {

    @Override
    public void create() {
        createFile("service-page.tpl", "PageService");
        createFile("service-select.tpl", "SelectService");
        createFile("service-add.tpl", "AddService");
        createFile("service-update.tpl", "UpdateService");
    }

    private void createFile(String tplFile, String suffix){
        final String template = getTemplate(tplFile);
        TextHelper builder = TextHelper.loadString(template);
        builder.setValue("rootPkg", projectVO.getRootPkg());
        builder.setValue("modelName", projectVO.getModuleName());
        builder.setValue("entityName", entityVO.getEntityName());
        builder.setValue("entityVar", entityVO.getEntityVar());
        builder.setValue("primaryKeyUpper", StringUtil.upperFirst(codeVO.getPrimaryKey()));
        String text = builder.getText();
        writeText(text, getJavaFile("service", entityVO.getEntityVar(), suffix));
    }



}
